const Joi = require('joi')

/**
 * string()  只能是字符串
 * alphanum() 值只能包含 a-zA-Z0-9 的字符串
 * min(length) 最小长度
 * max(length) 最大长度
 * requires()  值必填
 * pattern(正则表达式)  值必须符合正则表达式的规则 
 */

const username = Joi.string().alphanum().min(3).max(32).required()
const password = Joi.string().pattern(/^[\S]{6,15}$/).required()
//  校验 rePassword 值与 password 相同并且必填
const rePassword = Joi.any().valid(Joi.ref('password')).required().label('rePassword')

exports.Register_schema = {
    body: {
        username,
        password,
        rePassword
    }
}
exports.Login_schema = {
    body: {
        username,
        password,
    }
}